﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Data;
using System.Data.SqlClient;
using Server_NhaSach.DataTransferObject;
using Server_NhaSach.DataAccess.LogicLayer;
namespace Server_NhaSach.BusinessLayer
{
    public class CTNhapHangBlo
    {
        #region "Khai báo các biến"
        private CTNhapHangDAO da;
        private CTNhapHangDTO _CTNH;
        private string _error;
        #endregion

        #region "Khai báo các thuộc tính"
        public string Error
        {
            get { return _error; }
        }
        public CTNhapHangDTO CTNH
        {
            get { return _CTNH; }
            set { _CTNH = value; }
        }
        #endregion

        #region "Khai báo các Method"
        public CTNhapHangBlo()
        {
            _CTNH = new CTNhapHangDTO();
            da = new CTNhapHangDAO();
        }
        public bool InsertCTNH(string maMH, string maHDNH, int soLuong, double donGia, float chietKhau, double thanhTien)
        {
            CTNH = new CTNhapHangDTO(maMH, maHDNH, soLuong, donGia, chietKhau, thanhTien);
            if (!da.InsertCTNH(CTNH))
            {
                _error = da.Error;
                return false;
            }
            return true;
        }
        public bool UpdateCTNH(string maMH, string maHDNH, int soLuong, double donGia, float chietKhau, double thanhTien)
        {
            CTNH = new CTNhapHangDTO(maMH, maHDNH, soLuong, donGia, chietKhau, thanhTien);
            if (!da.UpdateCTNH(CTNH))
            {
                _error = da.Error;
                return false;
            }
            return true;
        }
        public bool DeleteCTNH(string MaMH,string MaHDNH)
        {
            if (!da.DeleteCTNH(MaMH, MaHDNH))
            {
                _error = da.Error;
                return false;
            }
            return true;
        }
        public DataSet LayDS_CTNhapHang()
        {
            DataSet ds = new DataSet();
            ds = da.LayDS_CTNhapHang();
            return ds;
        }
        #endregion
    }
}